package com.zls.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zls.pojo.SysUser;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface SysUserMapper extends BaseMapper<SysUser> {
    @Select("<script>" +
            "select * from sys_user where status =1" +
            "<if test='queryString!=null'> and username like concat( '%',#{queryString},'%')" +
            "limit #{currentPage},#{pageSize}</if>" +
            "<if test='queryString==null'>limit #{currentPage},#{pageSize}</if> "+
            "</script>")
    List<SysUser> findPage(@Param("currentPage") Integer currentPage, @Param("pageSize") Integer pageSize, @Param("queryString") String queryString);

    //查询总记录数
    @Select("<script>" +
            "select count(*) from sys_user where status =1" +
            "<if test='queryString!=null'> and username like concat( '%',#{queryString},'%') </if>" +
            "</script>")
    Long count(String queryString);

    //逻辑删除
    @Update("update sys_user set status=0 where id=#{id}")
    int deleteId(int id);
}
